package cc.inik.sqlite;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

import androidx.annotation.Nullable;

public class DBHelper extends SQLiteOpenHelper {

    private  static final String TAG = "SQLite";

    public DBHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, null, version);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        Log.e(TAG,"执行了onCreate方法");
        sqLiteDatabase.execSQL("CREATE TABLE person(uid  INTEGER PRIMARY KEY AUTOINCREMENT,uname VARCHAR(20) NOT NULL,pwd VARCHAR(20) NOT NULL)");
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
        Log.e(TAG,"执行了onUpgrade方法");
        sqLiteDatabase.execSQL("ALTER TABLE person ADD phone VARCHAR(20) NOT NULL");
    }
}
